/*
 *
 * *******************************************************************
 *   @项目名称: BHex Android
 *   @文件名称: ConfigApi.java
 *   @Date: 11/29/18 3:21 PM
 *   @Author: chenjun
 *   @Copyright（C）: 2018 BlueHelix Inc.   All rights reserved.
 *   注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的.
 *  *******************************************************************
 *
 */

package io.bhex.sdk.config;

import android.util.Log;

import io.bhex.baselib.network.BParamsBuilder;
import io.bhex.baselib.network.HttpUtils;
import io.bhex.baselib.network.listener.SimpleResponseListener;
import io.bhex.baselib.network.params.GetParams;
import io.bhex.baselib.network.params.PostParams;
import io.bhex.sdk.Urls;
import io.bhex.sdk.config.bean.ConfigBean;
import io.bhex.sdk.config.bean.IndexConfigBean;
import io.bhex.sdk.config.bean.IndexMudulesResponse;
import io.bhex.sdk.config.bean.KycInfoConfigResponse;
import io.bhex.sdk.config.bean.LanguageListResponse;
import io.bhex.sdk.config.bean.ShareConfigBean;
import io.bhex.sdk.config.bean.TokenBriefIntroductionBean;


public class ConfigApi {
    public static void getFunctionConfig(SimpleResponseListener<ConfigBean> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_BASIC_FUNCTIONS_CONFIG_URL)
                .build();
        HttpUtils.getInstance().request(params, ConfigBean.class, listener);
    }

    /**
     * 获取基础信息接口
     * @param listener
     */
    public static void getConfig(SimpleResponseListener<ConfigBean> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_BASIC_CONFIG_URL)
                .build();
        HttpUtils.getInstance().request(params, ConfigBean.class, listener);
    }

    /**
     * 获取语言配置
     * @param listener
     */
    public static void getLanguage(SimpleResponseListener<LanguageListResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_COMMON_LANGUAGE_LIST_URL)
                .build();
        HttpUtils.getInstance().request(params, LanguageListResponse.class, listener);
    }

    /**
     * 获取分享配置信息
     * @param listener
     */
    public static void getShareConfig(SimpleResponseListener<ShareConfigBean> listener) {
        Log.d("ConfigAPI","API_SHARE_CONFIG_URL=="+Urls.API_SHARE_CONFIG_URL);
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_SHARE_CONFIG_URL)
                .build();
        HttpUtils.getInstance().request(params, ShareConfigBean.class, listener);
    }

    /**
     * 获取INDEX Config
     * @param listener
     */
    public static void getIndexConfig(SimpleResponseListener<IndexConfigBean> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_INDEX_CONFIG_URL)
                .build();
        HttpUtils.getInstance().request(params, IndexConfigBean.class, listener);
    }

    /**
     * 获取token简介
     * @param tokenId
     */
    public static void getTokenInfo(String tokenId,SimpleResponseListener<TokenBriefIntroductionBean> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_TOKEN_BRIEF_INTRODUCTION_URL)
                .addParam("token_id",tokenId)
                .build();
        HttpUtils.getInstance().request(params, TokenBriefIntroductionBean.class, listener);
    }

    /**
     * APP模块配置
     * @param moduleTypes
     * @param lightModel
     */
    public static void getIndexModules(String moduleTypes,int lightModel,SimpleResponseListener<IndexMudulesResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_INDEX_MODULES_URL)
                .addParam("moduleTypes",moduleTypes)
                .addParam("lightModel",lightModel)
                .build();
        HttpUtils.getInstance().request(params, IndexMudulesResponse.class, listener);
    }

    /**
     * 自定义接口
     * @param customKeys
     */
    public static void getCustomKV(String customKeys,SimpleResponseListener<KycInfoConfigResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_BASIC_CUSTOM_KV_URL)
                .addParam("custom_keys",customKeys)
                .build();
        HttpUtils.getInstance().request(params, KycInfoConfigResponse.class, listener);
    }

    /**
     * 请求备用域名
     * @param domainReqUrl
     * @param listener
     */
    public static void requestBackupDomain(String domainReqUrl, SimpleResponseListener<BackupDomainResponse> listener) {
        GetParams params = BParamsBuilder.get()
                .url(domainReqUrl)
                .build();
        HttpUtils.getInstance().request(params, BackupDomainResponse.class, listener);
    }
}
